home *** CD-ROM | disk | FTP | other *** search
- ## WebCast.tg
- # Copy the file from SORUCE LOCATION to TEMP LOCATION
- # Then, crop and convert to JPG and leave in OUT_NAME
- # Finally FTP to remote website to DST_NAME
- ##
- # script assumes:
- # 1. SRC_DIR is set to a directory to look for .BMP files. Eg. "f:\"
- # 2. TEMP_NAME is set to a temp name for the file. Eg. "d:\imgstore\temp.bmp"
- # 3. OUT_NAME is set to a full output name. Eg. "d:\imgstore\out.jpg"
- # 4. DST_NAME is the output name on the remote ftp server. Eg. "pages/out.jpg"
- # 5. the environment variables: USER.SERVER, USER.USERID, and USER.PASSWORD are set elsewhere,
- # perhaps in the global (computer) environment or the local environment of WinCron via
- # Config.tg or AutoRun.tg. You could also set them here in this this script or hard-code the
- # values passed to -ftp connect.
-
- # WebCast
- {
- -name WebCast
- -start
-
- ###
- # Copy the file from SORUCE LOCATION to remote (FTP) DESTINATION
- # (I use two separate computers for this, but this need not be the case.)
- # Then, crop and convert to JPG and leave in OUT_NAME
- # Finally FTP to remote website to DST_NAME
- ###
-
- ###
- # setup source, destination and temp names
- # You can either uncomment these lines or set these values in your
- # computer environment. I like to set them in my environment.
- # SRC_DIR=f:\
- # TEMP_NAME=d:\imgstore\temp.bmp
- # OUT_NAME=d:\imgstore\out.jpg
- # DST_NAME=pages/out.jpg
-
- # set up an error handler for file operations
- -action -onerror file_operation_fail
-
- # supply input mask and output variable name
- -action -set OP=getFile
- -action -print trying to GET oldest filename from MASTER computer
- -action -getFile -oldest "%SRC_DIR%*.bmp" FILE_NAME
-
- # move the file to a temp location
- -action -set OP=move
- -action -print Trying to move %FILE_NAME% to %TEMP_NAME%
- -action -move %FILE_NAME% %TEMP_NAME%
-
- # read the dib
- -action -set OP=dibRead
- -action -print Reading DIB %TEMP_NAME%
- -action -img dibRead handle %TEMP_NAME%
-
- # crop the dib
- -action -set OP=dibCrop
- -action -print Cropping DIB %TEMP_NAME%
- -action -img dibCrop handle 640 480
-
- # write the JPG file
- -action -set OP=dibWriteJPG
- -action -print Writing JPG %OUT_NAME%
- -action -img dibWriteJPG handle %OUT_NAME%
-
- # free memory
- -action -set OP=dibRelease
- -action -print Freeing DIB memory
- -action -img dibRelease handle
-
- # delete the temp file
- -action -set OP=delete
- -action -print Delete %TEMP_NAME%
- -action -delete %TEMP_NAME%
-
- ##
- # PUT OUT_NAME on the remote server
- #
- -action -print connecting to remote ftp server
- -action -onerror connect_fail
- -action -ftp connect handle %USER.SERVER% 21 %USER.USERID% %USER.PASSWORD%
- -action -print putting file on remote ftp server
- -action -onerror operation_fail
- -action -ftp put handle %OUT_NAME% %DST_NAME% 1
- -action -ftp close handle
-
- -action -delete %OUT_NAME%
- -action -print done!
- -action -inc 0 0 1 0
- }
-
- # file operation failed
- {
- -name file_operation_fail
- -action -print file operation %OP% failed
- -action -print will try later
- -action -return break
- }
-
- # connection failed
- {
- -name connect_fail
- -action -print FTP open connection failed with error:
- -action -print %TG.LAST_ERROR%
- -action -print will try later
- -action -delete %OUT_NAME%
- -action -return break
- }
-
- # operation failed
- {
- -name operation_fail
- -action -print FTP put failed with error:
- -action -print %TG.LAST_ERROR%
- -action -print Closing connection...
- -action -ftp close handle
- -action -print will try later
- -action -delete %OUT_NAME%
- -action -return break
- }
-